package com.chb.system.controller.apis;

import com.chb.system.annotation.OperLogAnnotation;
import com.chb.system.service.CheckItemService;
import com.chb.system.vo.CheckItemVo;
import com.chb.system.vo.RoleVo;
import com.hos.entity.sys.CheckItem;
import com.hos.entity.sys.Role;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/12/14 15:54
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/system/api/checkItem")
@Api(value = "项目查询相关接口", tags = "项目相关接口")
public class APICheckItemController {
    @Autowired
    private CheckItemService checkItemService;

    @GetMapping("selectAllCheckItem")
    @ApiOperation(value = "获取所有可用的项目信息")
    public Result<List<CheckItem>> selectAllCheckItem() {
        return new Result<>(200, "查询成功", checkItemService.selectAllCheckItem());
    }

    @PostMapping("findCheckItemByCond")
    @ApiOperation(value = "条件查询项目信息")
    public Result<Page<CheckItem>> selectAllCheckItem(@RequestBody CheckItemVo checkItemVo) {
        return new Result<>(200, "查询成功", checkItemService.findCheckItemByCond(checkItemVo));
    }

    @PostMapping("updateCheckItem")
    @ApiOperation(value = "修改项目费用信息")
    @OperLogAnnotation(business_type = "系统业务-修改项目费用", operator_type = 1)
    public Result updateCheckItem(@RequestBody CheckItem checkItem) {
        return new Result<>(200, "修改成功", checkItemService.updateCheckItem(checkItem));
    }

    @PostMapping("/getCheckItemByCheckItemId/{checkItemId}")
    @ApiOperation(value = "根据项目费用Id查询到一个项目费用")
    public Result<CheckItem> getCheckItemByCheckItemId(@PathVariable Long checkItemId) {
        return new Result<CheckItem>(200, "查询成功", checkItemService.getCheckItemById(checkItemId));
    }

    @PostMapping("/addCheckItem")
    @ApiOperation(value = "添加项目费用")
    @OperLogAnnotation(business_type = "系统业务-增加项目费用", operator_type = 1)
    public Result<Integer> addCheckItem(CheckItem checkItem) {
        return new Result<>(200, "添加成功", checkItemService.addCheckItem(checkItem));
    }

    @DeleteMapping("deleteCheckItemByCheckItemIds/{ids}")
    @ApiOperation(value = "根据项目费用ID永久删除项目费用")
    @OperLogAnnotation(business_type = "系统业务-删除项目费用", operator_type = 1)
    public Result<Integer> deleteCheckItemByCheckItemIds(@PathVariable List<Long> ids) {
        return new Result<>(200, "删除成功", checkItemService.deleteCheckItemByIds(ids));
    }


}